<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="form" :inline="true"  label-width="90px">
            <el-form-item label="园所名称：" prop="title">
          <el-input v-model="queryParams.title" @input="handleInput" placeholder="请输入园所名称" clearable size="small" @keyup.enter.native="handleQuery" />
        </el-form-item>
            <el-form-item label="园所性质：" prop="schoolType">
              <el-select v-model="queryParams.schoolType" placeholder="请选择园所性质" clearable size="small">
                <el-option v-for="dict in schoolTypeOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
            </el-form-item>
           <el-form-item label="地区类型：" prop="nature">
              <el-select v-model="queryParams.nature" placeholder="请选择地区类型" clearable size="small">
                <el-option v-for="dict in schoolNatureOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
           </el-form-item>
           <!-- <el-form-item label="年级" prop="type">
              <el-select v-model="querys.nature" placeholder="请选择地区类型" clearable size="small">
                <el-option v-for="dict in schoolNatureOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
           </el-form-item>
           <el-form-item label="班级" prop="type">
              <el-select v-model="querys.nature" placeholder="请选择地区类型" clearable size="small">
                <el-option v-for="dict in schoolNatureOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
           </el-form-item> -->
           <el-form-item label="学生姓名" prop="name">
             <el-input v-model="queryParams.name" placeholder="请输入学生姓名" maxlength="25" onkeyup="queryParams.name=queryParams.name.replace(/[^\u4E00-\u9FA5]/g,'')" clearable size="small" />
           </el-form-item>
           <el-form-item>
             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
           </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="sickenList" max-height="700px'">
        <el-table-column type="index" label="序号" align="center" :index="customeIndex" width="80"></el-table-column>
          <el-table-column  align="center" label="园所名称" prop="title" ></el-table-column>
          <el-table-column  align="center" label="地区类型" prop="nature"  :formatter="schoolNatureFormat" ></el-table-column>
          <el-table-column  align="center" label="园所性质" prop="schoolType" :formatter="schoolTypeFormat" ></el-table-column>
          <el-table-column  align="center" label="年级" prop="specTitle" :formatter="gradeTypeFormat" ></el-table-column>
          <el-table-column  align="center" label="班级" prop="classTitle" ></el-table-column>
          <el-table-column  align="center" label="学生姓名" prop="name"  ></el-table-column>
          <el-table-column  align="center" label="性别" prop="sex"  :formatter="sexFormat"></el-table-column>
          <el-table-column label="患病时间" align="center"  prop="illnessDate"/>
          <el-table-column label="是否传染" align="center"  prop="ifInfect" :formatter="isCurrentFormat1"/>
          <el-table-column label="是否治愈" align="center"  prop="cureStatus" :formatter="isCurrentFormat"/>
          <el-table-column label="病情描述" align="center" prop="remark"   :show-overflow-tooltip="true"/>
          <el-table-column label="疾病处理方式" align="center"  prop="method"   :formatter="illnessProcessFormat"/>
          <el-table-column label="治疗建议" align="center" prop="treatAdvise"   :show-overflow-tooltip="true"> </el-table-column>
           </el-table>
           <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList" />
    </div>
</template>
<script>
import { getVolist} from "@/api/qu/qyjbglyj";
import { selectSemster} from "@/api/base/semster";
import moment from "moment";
 export default {
   name: "StudentCheck",
   data() {
     return {
        radioTimeChange: "Day",
        type:'1',
        timeLable:'日期：',
        value1:'',
       // 查询参数
       queryParams: {
         pageNum: 1,
         pageSize: 10,
         nature:'',
         schoolType:'',
         nature:'',
         name:''
       },
       loading:false,
       typeOptions:[],
       schoolNatureOptions:[],
       schoolTypeOptions:[],
       sexOptions:[],
       gradeOptions:[],
       isCurrentOptions:[],
       illnessProcessOptions:[],
       total:0,
       sickenList:[],
     };
   },
   created() {
     this.getList()
      this.getDicts("school_nature").then(response => {
       this.schoolNatureOptions = response.data;
     });
     this.getDicts("park_type").then(response => {
          this.schoolTypeOptions = response.data;
        });
      this.getDicts("sys_user_sex").then(response => {
        this.sexOptions = response.data;
      });
      this.getDicts("year_type").then(response => {
          this.gradeOptions = response.data;
        });
    this.getDicts("yes_or_no").then(response => {
         this.isCurrentOptions = response.data;
       });
         //疾病处理方式字典
     this.getDicts("illness_process_mode").then(response => {
       this.illnessProcessOptions = response.data;
     });
   },
   mounted(){
   },
   methods: {
    async getList(){
         this.loading=true;
         try {
           const obj ={
              title:this.queryParams.title,
              nature:this.queryParams.nature,
              schoolType:this.queryParams.schoolType,
              name:this.queryParams.name,
              pageNum: this.queryParams.pageNum,
              pageSize: this.queryParams.pageSize,
           }
           console.log(obj,'------obj')
          const data =  await getVolist(obj);
          this.sickenList=data.rows;
          this.total=data.total;
          this.loading=false;
         } catch (error) {
           console.log(error);
         }
     },
      // 性别字典翻译
    sexFormat(row, column) {
      return this.selectDictLabel(this.sexOptions, row.sex);
    },
      // 是否治愈当前字典翻译
      isCurrentFormat(row, column) {
      return this.selectDictLabel(this.isCurrentOptions, row.cureStatus);
    },
     // 年级字典翻译
     gradeTypeFormat(row, column) {
            return this.selectDictLabel(this.gradeOptions, row.specTitle);
         },
     // 是否传染当前字典翻译
     isCurrentFormat1(row, column) {
      return this.selectDictLabel(this.isCurrentOptions, row.ifInfect);
    },
     // 疾病处理方式当前字典翻译
     illnessProcessFormat(row, column) {
      return this.selectDictLabel(this.illnessProcessOptions, row.method);
    },
     // 园所性质字典翻译
     schoolTypeFormat(row, column) {
      return this.selectDictLabel(this.schoolTypeOptions, row.schoolType);
    },
    //地区类型字典翻译
    schoolNatureFormat(row, column) {
      return this.selectDictLabel(this.schoolNatureOptions, row.nature);
    },
    handleInput(val){
          let regtszf = /[`~!@#$%^&*()_\-+=<>?:"{}|,./;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘'，。、]/g // 特殊字符正则
          let regkg = /[ ]/g// 空格正则
          this.queryParams.title = val.replace(regtszf, '').replace(regkg, '')
         },
      // 序号
      customeIndex(index){
           return index+1+(this.queryParams.pageNum-1)*this.queryParams.pageSize
        },
        /** 搜索按钮操作 */
     handleQuery() {
        this.getList()
     },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("form");
          this.handleQuery()
     },

        }
 };
</script>
